﻿using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ViewROI
{
    public class HWindow
    {
        public Action<HImage> action;
        public Action<List<double>> dispRRects;
        public Action<List<float>> dispCircle;
        public Action<int> clearWindow;
        public Action<List<double>> dispArrow;
        public Action<List<double>> dispXLDArrow;
        public Action<List<float>> dispLine;
        public Action<Rectangle> zoomWindow;
        public Action<List<double>> drawRectangle1;

        public Action flush;

        public void SetDraw(string s)
        {

        }

        public void FlushGraphic()
        {
            if (flush != null)
                flush();
        }
        public void ZoomWindow(Rectangle rect)
        {
            zoomWindow(rect);
        }
        public void SetLineWidth(int w)
        {

        }

        public Color SetColor(Color color)
        {
            return color;
        }

        public void SetLineStyle(string style) { }

        public void DispRectangle1(double row1, double col1, double row2, double col2)
        {
            drawRectangle1?.Invoke(new List<double>() { row1, col1, row2, col2 });
        }
        public void DispRectangle2(double midR, double midC, double phi, double length1, double length2) 
        {
            List<double> rectPara = new List<double>(5) { midR, midC, phi, length1, length2 };

            //RotatedRect rotatedRect = new RotatedRect(new Point2f((float)midC, (float)midR), new Size2f((float)length1 * 2, (float)length2 * 2), -(float)(phi * 180 / Math.PI));
            this.dispRRects?.Invoke(rectPara);
            
        }
        public void DispCircle(double midR, double midC, double radius)
        {
            dispCircle?.Invoke(new List<float>(3) { (float)midR, (float)midC, (float)radius });
        }
        public void DispArrow(double y1, double x1, double y2, double x2, double thick) 
        {         

            List<double> param = new List<double>() { x1, y1, x2, y2, thick };
            this.dispArrow?.Invoke(param);
        }

        public void SetColored(int co) { }

        public void SetLut(string lu) { }

        public void SetPaint(string pa) { }

        public void SetShape(string sh) { }

        public void Dispose() { }

        public void OpenWindow(int a, int b, int c, int d, string e, string f, string g)
        {

        }

        public void SetPart(int x, int y, int z, int i)
        {

        }

        public void SetWindowExtents(int x, int y, int z, int i)
        {

        }

        public void DispLine(double y1, double x1, double y2, double x2)
        {
            dispLine?.Invoke(new List<float>()
            {
                (float)x1, (float)y1, (float)x2, (float)y2
            });
        }
        public void ClearWindow() 
        {
            if (clearWindow != null)
            clearWindow(0);
        }

        public void DispObj(HObject ho)
        {
            //dispXLDArrow
        }

        private void coord2Coord(OpenCvSharp.Point point)
        {
            
        }

    }
}
